<style>
    #notice-detail {
        padding: 20px 25px 25px 0;
    }

    .layui-form-label {
        width: 140px;
    }

    .layui-input-block {
        margin-left: 170px;
    }

    #notice-detail span {
        margin: 0 0 2px 3px !important;
    }

    .layui-layer-page .layui-layer-content {
        overflow: visible !important;
    }
</style>
<div class="layui-fluid" id="notice-detail">
    <form class="layui-form" lay-filter="notice-detail-form">
        <div class="layui-form-item website-hide">
            <label class="layui-form-label website-form-item-require">通知公告id：</label>
            <div class="layui-input-block">
                <input type="text" name="noticeId" data-th-value="${notice.noticeId}">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md6">
                <label class="layui-form-label website-form-item-require">标题：</label>
                <div class="layui-input-block">
                    <input type="text" name="title" data-th-value="${notice.title}" readonly class="layui-input">
                </div>
            </div>
            <div class="layui-col-md6">
                <label class="layui-form-label">发布状态：</label>
                <div class="layui-input-block">
                    <input type="text" name="isPublish" readonly class="layui-input">
                </div>
            </div>

        </div>
        <div class="layui-form-item">
            <div class="layui-col-md12">
                <label class="layui-form-label website-form-item-require">类型：</label>
                <div class="layui-input-block">
                    <!--<select name="typeCode" >
                        <option value="">请选择</option>
                        <option
                                th:selected="${ notice.typeCode eq item.code}"
                                th:selected="${ notice.typeCode eq item.code}"
                                th:each="item : ${noticeType}"
                                th:value="${item.code}"
                                th:text="${item.name}">
                        </option>
                    </select>-->
                    <input type="text" name="typeCode" readonly class="layui-input">
                </div>
            </div>
        </div>
        <div class=" website-hide" id="jxTimeDiv">
            <div class="layui-row layui-form-item">
                <div class="layui-col-md4">
                    <label class="layui-form-label website-form-item-require">结项申请开始时间：</label>
                    <div class="layui-input-block">
                        <input type="text" name="selectBeginTime" class="layui-input" readonly id="jxBeginTime">
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label website-form-item-require">结项申请结束时间：</label>
                    <div class="layui-input-block">
                        <input type="text" name="selectEndTime" class="layui-input" readonly>
                    </div>
                </div>
            </div>
            <div class="layui-row layui-form-item">
                <div class="layui-col-md4">
                    <label class="layui-form-label website-form-item-require">期次：</label>
                    <div class="layui-input-block">
                        <input type="text" name="period" class="layui-input" readonly>
                    </div>
                </div>
            </div>
        </div>
        <div class="website-hide" id="jxjgDiv">
            <div class="layui-row layui-form-item">
                <div class="layui-col-md6">
                    <label class="layui-form-label website-form-item-require">期次：</label>
                    <div class="layui-input-block">
                        <input type="text" name="period" id="jxjgPeriod" readonly class="layui-input">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item website-hide" id="selectTimeDiv">
            <div class="layui-row">
                <div class="layui-col-md4">
                    <label class="layui-form-label website-form-item-require">征集开始时间：</label>
                    <div class="layui-input-block">
                        <input type="text" name="selectBeginTime" class="layui-input" readonly id="selectBeginTime">
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label website-form-item-require">征集结束时间：</label>
                    <div class="layui-input-block">
                        <input type="text" name="selectEndTime" class="layui-input" readonly id="selectEndTime">
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label website-form-item-require">年份：</label>
                    <div class="layui-input-block">
                        <input type="text" name="year" class="layui-input" readonly>
                    </div>
                </div>
            </div>
        </div>
        <div class="website-hide" id="submitTimeDiv">
            <div class="layui-form-item ">
                <div class="layui-row">
                    <div class="layui-col-md6">
                        <label class="layui-form-label website-form-item-require">提交开始时间：</label>
                        <div class="layui-input-block">
                            <input type="text" name="submitBeginTime" class="layui-input" readonly id="submitBeginTime">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label website-form-item-require">意向表结束时间：</label>
                        <div class="layui-input-block">
                            <input type="text" name="intentionSubmitEndTime" class="layui-input" readonly
                                   id="intentionSubmitEndTime">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item ">
                <div class="layui-row">
                    <div class="layui-col-md6">
                        <label class="layui-form-label website-form-item-require">申请表结束时间：</label>
                        <div class="layui-input-block">
                            <input type="text" name="applySubmitEndTime" class="layui-input" readonly
                                   id="applySubmitEndTime">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label website-form-item-require">年份：</label>
                        <div class="layui-input-block">
                            <input type="text" name="year" class="layui-input" readonly>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="website-hide" id="lxDiv">
            <div class="layui-row layui-form-item">
                <div class="layui-col-md6">
                    <label class="layui-form-label website-form-item-require">年份：</label>
                    <div class="layui-input-block">
                        <input type="text" name="lxYear" class="layui-input" readonly id="lxYear">
                    </div>
                </div>
            </div>
        </div>
        <div class="website-hide" id="nlxDiv">
            <div class="layui-row layui-form-item">
                <div class="layui-col-md4">
                    <label class="layui-form-label website-form-item-require">年份：</label>
                    <div class="layui-input-block">
                        <input type="text" name="nlxYear" class="layui-input" readonly id="nlxYear">
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label website-form-item-require">拟立项开始时间：</label>
                    <div class="layui-input-block">
                        <input type="text" name="nlxBeginTime" class="layui-input" readonly id="nlxBeginTime">
                    </div>
                </div>
                <div class="layui-col-md4">
                    <label class="layui-form-label website-form-item-require">拟立项结束时间：</label>
                    <div class="layui-input-block">
                        <input type="text" name="nlxEndTime" class="layui-input" readonly id="nlxEndTime">
                    </div>
                </div>
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-row">
                <div class="layui-col-md12">
                    <label class="layui-form-label ">附件：</label>
                    <div class="layui-input-block">
                        <div id="filename" class="layui-form-mid layui-word-aux"><a
                                th:href="@{'download/' + ${itemFile.fileId}}"
                                th:text="${itemFile.name}"></a></div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-row">
                <div class="layui-col-md12">
                    <label class="layui-form-label website-form-item-require">内容：</label>
                    <div class="layui-input-block">
                        <textarea name="content" readonly placeholder="请输入内容" class="layui-textarea"
                                  th:text="${notice.content}"
                                  rows="10"></textarea>
                    </div>
                </div>
            </div>
        </div>

    </form>
</div>

<script data-th-inline="javascript">
    layui.use(['form', 'formSelects', 'dict'], function () {
        var $ = layui.$,
            formSelects = layui.formSelects,
            form = layui.form,
            dict = layui.dict,
            notice = [[${notice}]],
            topicPlan = [[${topicPlan}]];
        form.render();
        initFormValue();
        formSelects.render();

        function initFormValue() {
            var selectBeginTime = "";
            var selectEndTime = "";
            var submitBeginTime = "";
            var intentionSubmitEndTime = "";
            var applySubmitEndTime = "";
            var preItemEndTime = "";
            var preItemBeginTime = "";

            $("#selectTimeDiv").addClass("website-hide");
            $("#submitTimeDiv").addClass("website-hide");
            $("#jxTimeDiv").addClass("website-hide");
            $("#nlxDiv").addClass("website-hide");
            $("#lxDiv").addClass("website-hide");
            $("#jxjgDiv").addClass("website-hide");

            if (notice.typeCode === "notice_type_ktzj") {
                $("#selectTimeDiv").removeClass("website-hide");
                if (topicPlan.selectBeginTime) {
                    selectBeginTime = layui.util.toDateString(topicPlan.selectBeginTime, 'yyyy-MM-dd')
                }
                if (topicPlan.selectEndTime) {
                    selectEndTime = layui.util.toDateString(topicPlan.selectEndTime, 'yyyy-MM-dd')
                }

            } else if (notice.typeCode === "notice_type_ktzn") {

                $("#submitTimeDiv").removeClass("website-hide");
                if (topicPlan.submitBeginTime) {
                    submitBeginTime = layui.util.toDateString(topicPlan.submitBeginTime, 'yyyy-MM-dd')
                }
                if (topicPlan.intentionSubmitEndTime) {
                    intentionSubmitEndTime = layui.util.toDateString(topicPlan.intentionSubmitEndTime, 'yyyy-MM-dd')
                }

                if (topicPlan.applySubmitEndTime) {
                    applySubmitEndTime = layui.util.toDateString(topicPlan.applySubmitEndTime, 'yyyy-MM-dd')
                }

            } else if (notice.typeCode === "notice_type_jxgg") {
                $("#jxTimeDiv").removeClass("website-hide");
                if (topicPlan.selectBeginTime) {
                    selectBeginTime = layui.util.toDateString(topicPlan.selectBeginTime, 'yyyy-MM-dd')
                }
                if (topicPlan.selectEndTime) {
                    selectEndTime = layui.util.toDateString(topicPlan.selectEndTime, 'yyyy-MM-dd')
                }
            }  else if (notice.typeCode === "notice_type_jxjggg") {
                $("#jxjgDiv").removeClass("website-hide");

            } else if (notice.typeCode === "notice_type_nlxgg") {
                $("#nlxDiv").removeClass("website-hide");
                $("#nlxYear").val(topicPlan.year);
                if (topicPlan.preItemBeginTime) {
                    preItemBeginTime=layui.util.toDateString(topicPlan.preItemBeginTime, 'yyyy-MM-dd')
                }
                if (topicPlan.preItemEndTime) {
                    preItemEndTime=layui.util.toDateString(topicPlan.preItemEndTime, 'yyyy-MM-dd');
                }
            } else if (notice.typeCode === "notice_type_lxgg") {
                $("#lxDiv").removeClass("website-hide");
                $("#lxYear").val(topicPlan.year);
            }

            let dictType = dict.getByCode(notice.typeCode);
            let typeName = "";
            if (dictType) {
                typeName = dictType.name;
            }
            let year = "";
            let period = "";
            if (topicPlan) {
                if (topicPlan.period) {
                    period = topicPlan.period;
                }
                if (topicPlan.year) {
                    year = topicPlan.year;
                }
            }

            form.val("notice-detail-form", {
                "noticeId": notice.noticeId,
                "title": notice.title,
                "typeCode": typeName,
                "selectBeginTime": selectBeginTime,
                "selectEndTime": selectEndTime,
                "nlxBeginTime": preItemBeginTime,
                "nlxEndTime": preItemEndTime,
                "submitBeginTime": submitBeginTime,
                "intentionSubmitEndTime": intentionSubmitEndTime,
                "applySubmitEndTime": applySubmitEndTime,
                "isPublish": notice.isPublish ? "发布" : "未发布",
                "content": notice.content,
                "period": period,
                "year": year,
                'nlxYear': year,
                'lxYear': year
            });
        }
    });
</script>